﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SmartProject.Entity;

using NHibernate;
using NHibernate.Criterion;
using FluentNHibernate.Mapping;

namespace SmartProject.Entity
{
    public class Preference : EntityBase
    {
        public virtual string PrefName { get; set; }

        public virtual string PrefValue { get; set; }

        public static Preference GetPreference(ISession session, string name)
        {
            IList<ICriterion> expressions = new List<ICriterion>();
            expressions.Add(Restrictions.Eq("PrefName", name));
            IList<EntityBase> entities = Find(session, expressions, null, typeof(Preference));
            if (entities != null && entities.Count == 1)
            {
                return (Preference)entities[0];
            }
            return null;
        }
    }
}
